package com.ly.cloud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ly.cloud.dto.AprvCourseDto;
import com.ly.cloud.service.SpApplyCourseService;
import com.ly.cloud.vo.ApprovalDetailVo;
import com.ly.cloud.web.utils.WebResponse;

/**
 * 查询审批课程审批信息
 * 
 * @author siqi
 * @date 2018-12-22
 *
 */
@RestController
@RequestMapping("/courseAprvDetail")
public class CourseAprvController {

	@Autowired
	private SpApplyCourseService spApplyCourseService;

	/**
	 * 查询审批课程审批信息
	 * 
	 * @param kcbh
	 *            课程编号
	 * @return
	 */
	@RequestMapping(value = "/querAprvDetail", method = RequestMethod.GET)
	public WebResponse<List<ApprovalDetailVo>> querAprvDetail(@RequestParam String kcbh) {
		List<ApprovalDetailVo> list = spApplyCourseService.queryAprvDetail(kcbh);
		return new WebResponse<List<ApprovalDetailVo>>().success(list);
	}

	/**
	 * 审批课程申请信息
	 * 
	 * @param loginUserId
	 * @param dto
	 * @return
	 */
	@RequestMapping(value = "/aprvCourse", method = RequestMethod.POST)
	public WebResponse<Boolean> aprvCourse(@RequestHeader(required = false, value = "loginUserId") String loginUserId,
			@RequestBody AprvCourseDto dto) {
		Boolean isAprv = spApplyCourseService.aprvCourse(loginUserId, dto);
		return new WebResponse<Boolean>().success(isAprv);
	}
	
	/**
	 * 批量审批课程申请
	 * @param loginUserId
	 * @param dtoList
	 * @return
	 */
	@RequestMapping(value = "/batchAprvCourse",method = RequestMethod.POST)
	public WebResponse<Boolean> batchAprvCourse(@RequestHeader(required = false, value = "loginUserId") String loginUserId,
			@RequestBody List<AprvCourseDto> dtoList){
		Boolean isAprv = spApplyCourseService.batchAprvCourse(loginUserId, dtoList);
		return new WebResponse<Boolean>().success(isAprv);
	}

}
